from myelin.Ns import MYELIN, DC, DCTERMS
from myelin.rdf.bindery.ObjectTypes import ResourceTypeO, LiteralTypeO

from Resource import Resource

from ObjectTypes import \
    DocumentTypeO, DocumentTypeS, \
    ContainerTypeO, ContainerTypeS, \
    NodeGroupingTypeO, \
    UserAgentTypeO

from mappings import \
    DocumentMap, RelationsMap, \
    DocParentMap, \
    DocTranslationMap, DocTranslationOfMap, \
    DocGroupingMap


class Document(Resource):
    
    ModelTypes = (DocumentTypeO, DocumentTypeS)
    
    RDF_BINDINGS = {
        'mEffectiveDate'    : ((MYELIN, 'effectiveDate'), LiteralTypeO, DocumentMap),
        'mExpiryDate'       : ((MYELIN, 'expiryDate'), LiteralTypeO, DocumentMap),        
        'mTag'              : ((MYELIN, 'tag'), LiteralTypeO, DocumentMap),
        'mOrder_Key'        : ((MYELIN, 'order-key'), LiteralTypeO, DocumentMap),
        'mTranslation'      : ((MYELIN, 'translation'), ContainerTypeO, DocTranslationMap),
        'mTranslation_Of'   : ((MYELIN, 'translation'), ContainerTypeS, DocTranslationOfMap),
        'mGrouping'         : ((MYELIN, 'grouping'), NodeGroupingTypeO, DocGroupingMap),
        #'mBody'             : ((MYELIN, 'body'), LiteralTypeO, DocumentBodyMap),
        'mLast_Modifier'    : ((MYELIN, 'last-modifier'), UserAgentTypeO, DocumentMap),
        'mParentContains'    : ((MYELIN, 'contains'), ContainerTypeS, DocParentMap),
        'mAbstract'         : ((MYELIN, 'abstract'), LiteralTypeO, DocumentMap),
        #'mParentUnpublished': ((MYELIN, 'contains-unpublished'), ContainerTypeS, DocParentMap),
        #'mParentExpired'    : ((MYELIN, 'contains-expired'), ContainerTypeS, DocParentMap),
        
        'dcIdentifier'      : ((DC, 'identifier'), LiteralTypeO, DocumentMap),
        'dcType'            : ((DC, 'type'), ResourceTypeO, DocumentMap),
        'dcTitle'           : ((DC, 'title'), LiteralTypeO, DocumentMap),
        'dcAlternative'     : ((DC, 'alternative'), LiteralTypeO, DocumentMap),
        'dcCreator'         : ((DC, 'creator'), UserAgentTypeO, DocumentMap),
        'dcLanguage'        : ((DC, 'language'), LiteralTypeO, DocumentMap),
        'dcDescription'     : ((DC, 'description'), LiteralTypeO, DocumentMap),
        'dcSubject'         : ((DC, 'subject'), LiteralTypeO, DocumentMap),
        'dcDate'            : ((DC, 'date'), LiteralTypeO, DocumentMap),
        'dcPublisher'       : ((DC, 'publisher'), ResourceTypeO, DocumentMap),
        'dcFormat'          : ((DC, 'format'), LiteralTypeO, DocumentMap),
        
        'dctermsCreated'    : ((DCTERMS, 'created'), LiteralTypeO, DocumentMap),
        'dctermsModified'   : ((DCTERMS, 'modified'), LiteralTypeO, DocumentMap),
        
        'dctermsIsReferencedBy'     : ((DCTERMS, 'isReferencedBy'), ResourceTypeO, RelationsMap),
        'dctermsIsRequiredBy'     : ((DCTERMS, 'isRequiredBy'), ResourceTypeO, RelationsMap),
        'dcType'            : ((DC, 'type'), ResourceTypeO, RelationsMap),
        'dcSource'          : ((DC, 'source'), ResourceTypeO, RelationsMap),
        
        'mParent'           : ['mParentContains',],
        'mContainedBy'      : ['mParent','mTranslation_Of',],
        'mIsPartOf'         : ['mContainedBy','mGrouping',],
        'mTranslations'     : ['mTranslation','mTranslation_Of'],
    }

CLASS_TYPES = {
    MYELIN + 'Document' : Document,
}